package org.alex.fileSystem.controller;

import lombok.RequiredArgsConstructor;
import org.alex.fileSystem.service.FileService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


/**
 * @author : alex
 */
@RestController
@RequestMapping("file")
@RequiredArgsConstructor
public class FileController {
    private final FileService fileService;

    @PostMapping("/upload")
    public String upload(@RequestParam("file") MultipartFile file, @RequestParam("name") String objectName) {
        return fileService.upload(file, objectName);
    }

    @GetMapping("/preview")
    public String preview(@RequestParam("name") String objectName) {
        return fileService.preview(objectName);
    }
}
